<template>
	<view class="align-center">
		<!-- <view><text>支付成功！</text></view>
		<view><text>支付金额：{{amount}}元</text></view>
		<view><text>支付项目：{{moduleName}}</text></view>
		<view>
			<button type="primary" class="confirm-btn" @click="goTo('/pages/index/index')">返回首页</button>
		</view> -->
		<view class="tip">
			<text>长按保存图片或发送给朋友！</text>
		</view>
		<view>
			<image v-if="donationOrder.payVoucher" class="img" :src="apiurl+donationOrder.payVoucher" show-menu-by-longpress="true"></image>
		</view>
		<view>
			<!-- <button v-if="!isShow" @click="longClick()" type="primary">保存图片</button> -->
			<button  type="primary" class="confirm-btn" @click="goTo('/pages/index/index')">返回首页</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apiurl:'',
				amount:'',
				moduleName:'',
				id:'',
				donationOrder:{},
				share:{},
				isShow:false
			}
		},
		methods: {
			goTo(url){
				uni.switchTab({
					url: '/pages/index/index',
				})
			},
			//长按保存二维码
			longClick(){
				let that = this;
				uni.downloadFile({           //获得二维码的临时地址
					url:this.apiurl+this.donationOrder.payVoucher,
					success:(res)=>{
						//console.log('获取url',res)
						if(res.statusCode == 200){
							uni.saveImageToPhotosAlbum({
								filePath:res.tempFilePath,//传入临时地址
								success() {
									// that.$.ti_shi('保存成功')//封装的提示
									uni.showToast({
										title: '保存成功',
										duration: 1000
									});
									that.isShow = true;
								},
								fail() {
									// that.$.ti_shi('保存失败')
									uni.showToast({
										title: '保存失败',
										duration: 1000
									});
									that.isShow = false;
								}
							})
						}
					}
				})
			},

		},
		onLoad:function(option){
			
			 this.apiurl = getApp().globalData.staticUrl
		     this.amount = option.amount
			 this.moduleName = option.moduleName
			 this.id = option.id
			 this.$http.get('/temple.order/templeDonationOrder/api/queryById', {
			 	'id':this.id
			 }).then((res) => {
			 	this.donationOrder = res.data.result
			 })
		}
	}
</script>

<style scoped lang='scss'>
	.img{
		width: 100%;
		height: 560px;
	}
	
	.tip{
		padding-top: 10px;
		color:#999;
	}

</style>
